<template>
  <el-table
    :data="tableData"
    border
    style="width: 100%"
    size="mini">
    <el-table-column
      prop="id"
      label="ID"
      min-width="20%">
    </el-table-column>
    <el-table-column
      prop="tagName"
      label="标签名"
      min-width="10%">
    </el-table-column>
    <el-table-column
      prop="tagContent"
      label="标签内容"
      min-width="15%">
    </el-table-column>
    <el-table-column
      prop="parentId"
      label="父级ID"
      min-width="20%">
    </el-table-column>
    <el-table-column
      prop="createdTime"
      label="创建时间"
      min-width="20%">
    </el-table-column>
    <el-table-column
      fixed="right"
      label="操作"
      min-width="20%">
      <template slot-scope="scope">
        <el-button @click="detail(scope.row)" type="text" size="small">查看</el-button>
        <el-button type="text" @click="update(scope.row)" size="small">更新</el-button>
        <el-button type="text" @click="deleteTag(scope.row)" size="small">删除</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>

  export default {
    name: 'TagsTable',
    data: function() {
      return {

      }
    },
    props: {
      tableData: Array,
    },
    methods: {
      deleteTag(row) {
        this.$confirm('确定删除吗', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$api.deleteTag(row.id).then(res=>{
            this.$emit("update");
          });
        })
      },
      update(row) {
        this.$router.push({ name: "TagsAdd", params: {update:true, editable: true, readOnly:false, tagId: row.id}});
      },
      detail(row) {
        this.$router.push({ name: "TagsAdd", params: {update:false, editable: false, readOnly:true, tagId: row.id}});
      }
    }
  }
</script>

<style scoped>

</style>
